package com.pay.dubbo.wx.impl;

import javax.annotation.Resource;

import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.stereotype.Service;

import com.pay.beans.ReturnBean;
import com.pay.dubbo.wx.WxCustRelationQueryServiceFacade;
import com.pay.entity.wx.WxCustRelation;
import com.pay.mapper.wx.WxCustRelationMapper;

/**
 * @Description: 微信商户关系查询服务
 * @see: WxCustRelationQueryServiceFacade 此处填写需要参考的类
 * @version 2017年9月18日 下午4:35:56
 * @author jian.cao
 */
@Service("wxCustRelationQueryServiceFacade")
public class WxCustRelationQueryServiceFacadeImpl implements WxCustRelationQueryServiceFacade {


	private Log log = LogFactory.getLog(WxCustRelationQueryServiceFacadeImpl.class);

	@Resource
	private WxCustRelationMapper wxCustRelationMapper;

	@Override
	public ReturnBean wxCustRelationQueryByCustomerNo(String customerNo)
			throws Exception {
		try {
			log.info("wxCustRelationQueryByCustomerNo cusNo: "+customerNo);
			if (StringUtils.isNotBlank(customerNo)) {
				WxCustRelation wxCustRelation = wxCustRelationMapper.findByCustomerNo(customerNo);
				if (null==wxCustRelation) {
					log.info("wxCustRelationQueryByCustomerNo cusNo: "+customerNo+",wxCustRelationIsNull");
					return new ReturnBean("01","未绑定关系");	
				}else{
					if ("BINDING".equals(wxCustRelation.getBindingStatus())) {
						log.info("wxCustRelationQueryByCustomerNo cusNo: "+customerNo+",wxCustRelationIsLogIn");
						return new ReturnBean("00","已登录");
					}else{
						log.info("wxCustRelationQueryByCustomerNo cusNo: "+customerNo+",wxCustRelationIsLogOut");
						return new ReturnBean("02","已登出");
					}
				}
			}else{
				log.info("wxCustRelationQueryByCustomerNo cusNoIsNull");
				return new ReturnBean("98","商编为空");
			}
		} catch (Exception e) {
			e.printStackTrace();
			return new ReturnBean("99","系统异常");
		}
		
	}
	
	
}
